It is desirable to provide efficient and cost effective means for generating code for executing a stored code object in a data base. Such stored code objects must be executed for testing the object, determining the code coverage of the object, profiling the object, debugging the object, and for other similar reasons. Generating code used for testing, profiling, debugging, etc. such an object in most data base systems is highly expensive and inefficient in that it is time consuming and highly error-prone. For example, in an Oracle™ data base system using a PL/SQL™ query a stored code object or subprogram can be executed in one of two ways:                1) Use an Application programming interface such as Oracle Call Interface (OCI) that handles binding of parameters in addition to allowing the capability to execute an anonymous block that calls the subprogram; and        2) Use a PL/SQL development tool to construct an anonymous block that calls the subprogram.        
Using an application programming interface to write a program that executes a subprogram object is very time consuming and is not a practical alternative to execute subprograms. Constructing an anonymous block that calls the subprogram can also be very time consuming. SQL*Plus™ provides an ‘Execute’ command that allows users to execute subprograms. To bind parameters, SQL*Plus provides the command ‘Variable’. Using a combination of these two commands, a PL/SQL developer can execute subprograms. However, the SQL*Plus execution facility has only very limited use because of the following issues: (SQL*Plus and ORACLE and ORACLE7 are trademarks of ORACLE Corporation).                1) The ‘Execute’ command cannot be used to execute code objects that have complex parameter types in such PL/SQL records and PL/SQL table of records. Oracle7™ application programming interfaces do not support binding complex parameter types and so any implementations based on binding parameters will be limited by the fact that it will not be able to support complex parameter types.        2) Executing a code object with a number of parameters involves writing many, many ‘Variable’ commands which is very time consuming.        
In the past, many attempts have been made to automate data base testing and debugging. One such attempt was to use a compiler to store modified debug information and to construct debug tables to determine the actual data types of objects, as described in U.S. Pat. No. 5,361,351 titled “System & Method for supporting run-time data type identification of objects within a computer program.” Another such attempt is described in U.S. Pat. No. 5,519,859 titled “Method & Apparatus for Automatic table selection and generation of structured query language instructions,” which describes a system of automatically generating structured query language statements from data in predefined data tables and automatically selected output tables. In both of these cases an inordinate amount of time and effort is devoted to preparing and developing the data tables and compiler developed tables. Many other U.S. patents describe various debugging and testing systems for data bases but none of these which is known to Applicant provides the method and system of the present invention for automatically generating the parameters necessary to execute such a subprogram.
It would be advantageous to have a method for executing subprograms that allows programmers to input the values of the parameters and display the values of the output parameters after the subprogram executes. The method of generating and executing anonymous blocks automatically should eliminate coding errors while declaring parameter data types in the anonymous blocks, at the same time initializing values for the declared parameters. The method should also allow for executing subprograms that take complex user defined types as parameters, a task which is very laborious and error prone to do in a manual fashion. A complete execution facility should facilitate thorough testing of code objects during development. This should in turn save money by reducing logical errors when these code objects are later deployed and executed in production environments through client programs.
The present invention addresses these issues through a framework to provide a complete execution facility that can be used to execute a code object. It generates an executable anonymous block automatically by avoiding binding parameters altogether. Instead, variables corresponding to the parameter types are declared and initialized in the anonymous block. After the code object is called, the variables that correspond to the parameters that are bound by reference contain the values that are returned by the subprogram. The variable declarations and initializations are accomplished through a combination of parsing the source code, looking up the parameter information stored about the subprogram in the catalog and using a wizard to get the parameter values.